package com.hoshiicloud.user.service.rbac;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hoshiicloud.auth.vo.TokenUsersVO;
import com.hoshiicloud.common.exception.ServiceException;
import com.hoshiicloud.user.entity.company.Member;

import java.util.List;
import java.util.Map;

/**
 * 租户会员Service接口
 *
 * @author : yangcheng
 * @date : 2019/5/15 15:22
 * @mail : maiboyc@163.com
 **/
public interface IMemberService extends IService<Member> {

    /**
     * 根据id获取
     *
     * @param id ID
     * @return Member
     */
    Member getById(Long id);

    /**
     * 根据一组id
     *
     * @param ids id组
     * @return List<Member>
     */
    List<Member> getByIds(List<Long> ids);

    /**
     * 保存
     *
     * @param entity 实体对象
     * @return boolean
     */
    Long insert(Member entity) throws ServiceException;

    /**
     * 修改
     *
     * @param entity 实体对象
     * @return boolean
     */
    Long update(Member entity) throws ServiceException;


    /**
     * 根据条件查询租户会员信息
     *
     * @param entity 查询参数
     * @return List<Member>
     */
    List<Member> getMembers(Member entity);

    /**
     * 根据微信用户唯一openid获取租户会员
     *
     * @param wxOpenId 微信用户唯一id
     * @return Member
     */
    Member getMemberByWxOpenId(String wxOpenId);

    /**
     * 根据手机号码获取租户会员
     * @param companyId 租户id
     * @param mobile 手机号码
     * @return Member
     */
    Member getMemberByMobile(Long companyId,String mobile);

    /**
     * 根据openId和手机号码获取租户会员信息
     *
     * @param wxOpenId 微信openId
     * @param phone    手机号码
     * @return Member
     */
    Member getMemberByWxOpenIdOrMobile(String wxOpenId, String phone);

    /**
     * 删除
     *
     * @param id ID
     * @return boolean
     */
    boolean delete(Long id) throws ServiceException;

    /**
     * 查询租户会员信息和平台会员信息
     * 租户会员信息来自members，平台会员信息来自plat_consumer,以member_id关联
     *
     * @return Map<String, Object>
     */
    Map<String, Object> getMemberWithConsumerInfo(Map<String, Object> map, String key);

    /**
     * 根据租户姓名查询租户会员信息
     *
     * @param name
     * @return List<Member>
     */

    List<Member> memberList(String name);

    IPage<Member> getPage(IPage<Member> page, QueryWrapper<Member> queryWrapper, String key);


    TokenUsersVO getStoreMemberUserLoginDetail(Map<String, Object> map);

    TokenUsersVO getPlatformMemberUserLoginDetail(Map<String, Object> map);

}
